/*-
 * Copyright (c) 2006, 2007 FTS Team
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 4. Neither the name of the FTS Team nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *      FSDumper.hpp
 *
 * $FTS$
 */
#ifndef _FS_DUMPER_HPP__
#define _FS_DUMPER_HPP__ 1

/**
  @file FSDumper.hpp
  @brief Generic data dumper
*/
#include <DataDumper.hpp>

#define C_FTSS_MAGIC            0x53535446u // CTPP
#define C_FTSS_READABLE_LENGTH  128

namespace FTSS // FullTextSearchSystem
{

/**
  @class FSDumper FSDumper.hpp <FSDumper.hpp>
  @brief Generic dumpable object
*/
class FSDumper:
  public DataDumper
{
public:
	/**
	  @brief Constructor
	  @param iIFileHandle - file handle
	*/
	FSDumper(const INT_32 & iIFileHandle);

private:
	/**
	  @brief Start dump procudure
	  @param iObjectType - type of object
	  @param szObjectName - printable object name
	  @return 0 - if success, -1 - if error
	*/
	INT_32 StartDump(const INT_32 &  iObjectType, CCHAR_P szObjectName) throw();

	/**
	  @brief End dump procudure
	  @return 0 - if success, -1 - if error
	*/
	INT_32 EndDump() throw();

	/**
	  @brief Dump procudure
	  @param vData - data to restore
	  @param iDataLength - data size
	  @return 0 - if success, -1 - if error
	*/
	INT_32 Dump(const void * vData, const INT_32 & iDataLength) throw();

	/**
	  @brief Start restore procudure
	  @param iObjectType - type of object
	  @param szObjectName - printable object name
	  @return 0 - if success, -1 - if error
	*/
	INT_32 StartRestore(const INT_32 & iObjectType, CCHAR_P szObjectName) throw();

	/**
	  @brief End restore procudure
	  @return 0 - if success, -1 - if error
	*/
	INT_32 EndRestore() throw();

	/**
	  @brief Restore procudure
	  @param vData - data to restore
	  @param iDataLength - data size
	  @return 0 - if success, -1 - if error
	*/
	INT_32 Restore(void * vData, const INT_32 & iDataLength) throw();

private:
	/** File handle                                     */
	INT_32        iFileHandle;
	/** Useful buffer variable to read/write operations */
	UINT_32       iDummy;
	/** Readable description of object type             */
	CHAR_8        szReadableLength[C_FTSS_READABLE_LENGTH + 1];

};

} // namespace FTSS
#endif // _FS_DUMPER_HPP__
// End.
